# -*- coding:utf-8 -*-
import pymongo
import sys
import mysqldb

day = sys.argv[1]

mergeDir = "stat_user_visit_count"
subFix = "-ua-stat"

fileDir = mergeDir + "/" + str(day) + subFix
f = open(fileDir, "r")
for line in f:
    try:
        line = line.strip()
        logStr = line.split(" ")
        if (len(logStr) > 1):
            visitCnt = int(logStr[0])
            imei = logStr[1]
            mysqldb.insertUAcnt(imei, visitCnt, day)
    except Exception, e:
        print Exception, ":", e
f.close()
